package com.lmt_12;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws Exception {
        String data = "s数d";
        // encode
        byte[] bytes = data.getBytes();
        System.out.println(Arrays.toString(bytes));
        // GBK encode
        byte[] bytes1 = data.getBytes("GBK");
        System.out.println(Arrays.toString(bytes1));

        // decode  use the  default way to decode data
        String s = new String(bytes);
        System.out.println(s);
        // use given way to decode data
        String s1 = new String(bytes,"GBK"); // if you use wrong way to decode ,it would get wrong result.
        System.out.println(s1);

    }
}
